<?php
/**
 * This file is part of Word - A pure PHP library for reading and writing
 * word processing documents.
 *
 * Word is free software distributed under the terms of the GNU Lesser
 * General Public License version 3 as published by the Free Software Foundation.
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code. For the full list of
 * contributors, visit https://github.com/office/Word/contributors.
 *
 * @see         https://github.com/office/Word
 *
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
 */

namespace office\Word\Reader;

use Exception;
use office\Word\Word;
use office\Word\Reader\RTF\Document;

/**
 * RTF Reader class.
 *
 * @since 0.11.0
 */
class RTF extends AbstractReader implements ReaderInterface
{
    /**
     * Loads Word from file.
     *
     * @param string $docFile
     *
     * @return \office\Word\Word
     */
    public function load($docFile)
    {
        $Word = new Word();

        if ($this->canRead($docFile)) {
            $doc = new Document();
            $doc->rtf = file_get_contents($docFile);
            $doc->read($Word);
        } else {
            throw new Exception("Cannot read {$docFile}.");
        }

        return $Word;
    }
}
